﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ANZ_AIM_GUI.Utils;
using ANZ_AIM_DAL;
using ANZ_AIM_BLL;
using ANZ_AIM_BLL.Model;
using log4net;

namespace ANZ_AIM_GUI
{
    public partial class frmDataChangeUpload : Form
    {
        //log4net
        private static readonly ILog logger = LogManager.GetLogger(typeof(frmDataChangeUpload));

        public Dictionary<string, string> SaleChange_FieldLabelDict { get; set; }

        public frmDataChangeUpload()
        {
            InitializeComponent();
        }

        public frmDataChangeUpload(string batchFileID)
            : this()
        {
            try
            {
                BuildSaleChangeLabel();

                SaleChangeRequestBLL saleChangeRequestBll = new SaleChangeRequestBLL();
                DataTable dt = saleChangeRequestBll.GetByBatchFileChangeID(batchFileID);

                dgvData.DataSource = null;
                dgvData.Columns.Clear();
                dgvData.DataSource = dt;
                dgvData.AutoResizeColumns();

                PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(typeof(SaleChangeRequest));
                foreach (PropertyDescriptor prop in properties)
                {
                    dgvData.Columns[prop.Name].HeaderText = SaleChange_FieldLabelDict[prop.Name];
                }
            }
            catch (Exception ex) { throw ex; }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        public void BuildSaleChangeLabel()
        {
            try
            {
                SaleChange_FieldLabelDict = new Dictionary<string, string>();
                SaleChange_FieldLabelDict.Add("ID", "ID");
                SaleChange_FieldLabelDict.Add("ProfileID", "Profile ID");
                SaleChange_FieldLabelDict.Add("BatchFile", "Batch File");
                SaleChange_FieldLabelDict.Add("FieldChange", "Field Change");
                SaleChange_FieldLabelDict.Add("OldValue", "Old Value");
                SaleChange_FieldLabelDict.Add("NewValue", "New Value");
                SaleChange_FieldLabelDict.Add("BatchFileChangeID", "Batch File Change ID");
            }
            catch (Exception ex) { throw ex; }
        }
    }
}
